import { CacheKeyEnum } from '../constants/cacheKey'

const TokenKey = CacheKeyEnum.TOKEN_KEY
const RefreshTokenKey = CacheKeyEnum.REFRESH_TOKEN_KEY

const tokenObj = {
    setToken(token: string) {
        localStorage.setItem(TokenKey, token)
    },
    getToken() {
        return localStorage.getItem(TokenKey)
    },
    setRefreshToken(refreshToken: string) {
        localStorage.setItem(RefreshTokenKey, refreshToken)
    },
    getRefreshToken() {
        return localStorage.getItem(RefreshTokenKey)
    },
    removeAuth() {
        localStorage.removeItem(TokenKey)
        localStorage.removeItem(RefreshTokenKey)
    },
    setAuth(token: string, refreshToken: string) {
        this.setToken(token)
        this.setRefreshToken(refreshToken)
    }
}
export default tokenObj
